﻿using System;
using System.Collections.Generic;
using System.Data;
using Module.Core.DAO;
using Module.Core.EntitiesInfo;
using Module.Common.Models;

namespace Module.BusinessLogic.Implements
{
    public class LogMuaHangBL
	{
		/// <summary>
		/// Saves a record to the Log_MuaHang table.
		/// </summary>
        public static int Insert(LogMuaHangInfo logMuaHangInfo)
		{
			try
			{
			 return	new LogMuaHangDAO().Insert(logMuaHangInfo);
			}
			catch (Exception ex)
			{
				throw;
			}

		}

		/// <summary>
		/// Saves a record to the Log_MuaHang table.
		/// </summary>
        public static void Update(LogMuaHangInfo logMuaHangInfo)
		{
			try
			{
				new LogMuaHangDAO().Update(logMuaHangInfo);
			}
			catch (Exception ex)
			{
				throw;
			}

		}

		/// <summary>
		/// Delete a record from the Log_MuaHang table.
		/// </summary>
        public static void Delete(int logId)
		{
			try
			{
				new LogMuaHangDAO().Delete(logId);
			}
			catch (Exception ex)
			{
				throw;
			}

		}

		/// <summary>
		/// Selects a single record from the Log_MuaHang table.
		/// </summary>
        public static LogMuaHangInfo Select(int logId)
		{
			try
			{
				return new LogMuaHangDAO().Select(logId);
			}
			catch (Exception ex)
			{
				throw;
			}

		}

		/// <summary>
		/// Selects all records from the Log_MuaHang table.
		/// </summary>
        public static CHRTList<LogMuaHangInfo> SelectAll()
		{
			try
			{
				return new LogMuaHangDAO().SelectAll();
			}
			catch (Exception ex)
			{
				throw;
			}

		}


        public static CHRTList<LogMuaHangInfo> SearchAll(DateTime createdOnFrom, DateTime createdOnTo, int from, int to)
        {
            try
            {
                return new LogMuaHangDAO().SearchAll(createdOnFrom, createdOnTo, from, to);
            }
            catch (Exception ex)
            {
                throw;
            }

        }
        public static int GetCount(int logId, DateTime createOnFrom, DateTime createOnTo)
        {
            try
            {
                return new LogMuaHangDAO().GetCount(logId,createOnFrom, createOnTo);
            }
            catch (Exception)
            {

                throw;
            }
        }

        /// <summary>
        /// Lấy tổng số bản ghi
        /// </summary>        
        /// <param name="isTotalRow">=True lấy tổng sổ bản ghi</param>
        /// <returns></returns>
        public static int SelectCount(bool isTotalRow)
        {
            try
            {
                return new LogMuaHangDAO().SelectCount(isTotalRow);
            }
            catch (Exception ex)
            {
                throw;
            }

        }

        /// <summary>
        /// Lấy tổng số bản ghi
        /// </summary>
        /// <param name="beginRow">Bản ghi đầu tiên</param>
        /// <param name="endRow">Bản ghi kết thúc</param>
        /// <param name="orderByColumn">Điều kiện sắp xếp</param>       
        /// <returns></returns>
        public static DataTable Search(int beginRow, int endRow, string orderByColumn)
        {
            try
            {
                return new LogChuyenGoldDAO().Search(beginRow, endRow, orderByColumn);
            }
            catch (Exception ex)
            {
                throw;
            }

        }


        public static DataSet ListLogMuaHangPage(int logId, DateTime createOnFrom, DateTime createOnTo, int currPage, int recodperPage, int pageSize, int total, string link)
        {
            try
            {
                DataSet ds = new DataSet();

                ds = new LogMuaHangDAO().ListLogMuaHangPage(logId, createOnFrom, createOnTo, currPage, recodperPage, pageSize, total, link);
                if (ds != null)
                    return ds;
                return null;
            }
            catch (Exception ex)
            {
                throw;
            }

        }
	}
}
